package com.yuji.aacar.controller.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.yuji.aacar.R;
import com.yuji.aacar.bean.beans.Serial;
import com.yuji.aacar.widgets.textview.PingFangTextView;

import java.util.ArrayList;


public class CarSerialAdapter extends BaseAdapter {


    private Context context;
    private ArrayList<Serial> list;

    public CarSerialAdapter(Context context, ArrayList<Serial > list){
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }
    @Override
    public Object getItem(int position) {
        return list.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView= LayoutInflater.from(context).inflate(R.layout.activity_car_serial_item,null);
            viewHolder=new ViewHolder();
            viewHolder.title= (PingFangTextView) convertView.findViewById(R.id.car_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        viewHolder.title.setText(list.get(position).getSeriesName());
        return convertView;
    }
    public class ViewHolder{
        PingFangTextView title;
    }
}
